import React, { useState, useEffect } from 'react'
import { Table,Switch,Button  } from 'antd'
import { Link } from "react-router-dom"

export default function IndustrydictionaryList(props) {

  const [selectedRowKeys, setSelectedRowKeys] = useState([])
  const [resdata, setResData] = useState([])

  const [pageSize, setPageSize] = useState(10)
  const [pageSizeNow, setPageSizeNow] = useState(1)

  // 第几次


  const columns = [
    {
      title: '一级行业',
      dataIndex: 'yijihangye',
    },
    {
      title: '二级行业',
      dataIndex: 'erjihangye',
    },
    {
      title: '三级行业',
      dataIndex: 'sanjihangye',
    }
  ];

  const first = [
    'IT/互联网','金融业',<span><strong>广东</strong></span>,'建筑','商业服务','服装 / 贸易',<span><Button> 新增 </Button></span>
  ]

  const second = [
    '电子商务',<span><strong>深圳</strong></span>,'IT服务','计算机硬件','通信 / 电信运营增值服务',<span><Button> 新增 </Button></span>
  ]

  const third = [
    <span><Button> 新增 </Button></span>
  ]


  const data = [];

  for (let i = 0; i < 8; i++) {
    data.push({
      key: i,
      yijihangye:first[i],
      erjihangye:second[i],
      sanjihangye:third[i],
    })
  }


  const getPage = (pageSizeNow, pageSize) => {
    console.log(typeof pageSizeNow);
    console.log(typeof pageSize);
    setPageSize(pageSize)
    setPageSizeNow(pageSizeNow)
  }



  const onSelectChange = selectedRowKeys => {
    console.log('selectedRowKeys changed: ', selectedRowKeys);
    setSelectedRowKeys(selectedRowKeys)
  };

  const rowSelection = {
    selectedRowKeys,
    onChange: onSelectChange,
    selections: [
      Table.SELECTION_ALL,
      Table.SELECTION_INVERT,
      Table.SELECTION_NONE,
      {
        key: 'odd',
        text: 'Select Odd Row',
        onSelect: changableRowKeys => {
          let newSelectedRowKeys = [];
          newSelectedRowKeys = changableRowKeys.filter((key, index) => {
            if (index % 2 !== 0) {
              return false;
            }
            return true;
          });
          setSelectedRowKeys(newSelectedRowKeys)
        },
      },
      {
        key: 'even',
        text: 'Select Even Row',
        onSelect: changableRowKeys => {
          let newSelectedRowKeys = [];
          newSelectedRowKeys = changableRowKeys.filter((key, index) => {
            if (index % 2 !== 0) {
              return true;
            }
            return false;
          });
          setSelectedRowKeys(newSelectedRowKeys)
        },
      },
    ],
  };


  return (
    <div>
      <Table columns={columns} dataSource={data}
        // pagination={
        //   {
        //     total: data.length,
        //     showSizeChanger: true,
        //     showQuickJumper: true,
        //     showTotal: total => `共${Math.ceil(total / pageSize)}页/${total}条数据`,
        //     pageSizeOptions: ['10', '20', '30'],
        //     onChange: getPage,
        //   }
        // }

      />
    </div>
  );
}
